package com.leo;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.StrokeType;
import javafx.stage.Stage;

/**
 * @ClassName LineDemo
 * @Description
 * @Author wangss
 * @date 2020.07.01 22:41
 * @Version 1.0
 */
public class RectangleDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane an = new AnchorPane();

        HBox hBox = new HBox(200);
        hBox.setAlignment(Pos.CENTER);

        Rectangle rec = new Rectangle(0, 0, 200, 200);
        rec.setFill(Color.BLUE);

        Rectangle rec1 = new Rectangle(0, 0, 200, 200);
        rec1.setFill(Color.BLUE);
        rec1.setArcWidth(30d);
        rec1.setArcHeight(30d);

        Rectangle rec2 = new Rectangle(0, 0, 200, 200);
        rec2.setFill(Color.BLUE);
        rec2.setArcWidth(30d);
        rec2.setArcHeight(30d);
        rec2.setStroke(Color.RED);
        rec2.setStrokeWidth(2);
        rec2.setStrokeType(StrokeType.CENTERED);

        Rectangle rec3 = new Rectangle(0, 0, 200, 200);
        rec3.setFill(Color.BLUE);
        rec3.setArcWidth(30d);
        rec3.setArcHeight(30d);
        rec3.setStroke(Color.RED);
        rec3.setStrokeWidth(2);
        rec3.getStrokeDashArray().addAll(10d, 30d);

        hBox.getChildren().addAll(rec, rec1, rec2, rec3);

        an.getChildren().add(hBox);
        AnchorPane.setTopAnchor(hBox, 50d);
        AnchorPane.setLeftAnchor(hBox, 50d);

        Scene scene = new Scene(an);
        primaryStage.setScene(scene);
        primaryStage.setHeight(1000d);
        primaryStage.setWidth(1500d);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();
    }
}
